package leetcodecompetition.D336;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class T6316 {
    public int maxScore(int[] nums) {
        Arrays.sort(nums);
        int len=nums.length;
        int right=len;
        long sum=0;
        for (int i = 0; i < len; i++) {
            if (nums[i]>0){
                right=i;
                break;
            }
        }
        int re=len-right;
        for (int i = right; i <len ; i++) {
            sum=sum+nums[i];
        }
        for (int i = right-1; i >=0 ; i--) {
            sum=sum+nums[i];
            if (sum>0)re++;
            else break;
        }
        return re;
    }
    @Test
    public void test() {
        int []nums={00000,0,0,-1,1};
        System.out.println(maxScore(nums));
    }
}
